home *** CD-ROM | disk | FTP | other *** search
/ LiquidLibrary 2005 September / LiquidLibrary 2005 Sep - Disc 1.iso / pc / Portfolio Browser / Filters / PDF / LIB / gs_icc.ps < prev    next >
Text File  |  2003-01-03  |  3KB  |  105 lines

  1. %    Copyright (C) 2001 Aladdin Enterprises.  All rights reserved.
  2. % This software is licensed to a single customer by Artifex Software Inc.
  3. % under the terms of a specific OEM agreement.
  4.  
  5. % $RCSfile$ $Revision$
  6. % PostScript portion of ICCBased color space support
  7.  
  8. //userdict /.icc_comp_map_dict
  9.   << 1 /DeviceGray  3 /DeviceRGB  4 /DeviceCMYK >>
  10. put
  11.  
  12. colorspacedict /ICCBased
  13.   {
  14.     % Verify that the source object is an array, that it is at least of length
  15.     % two, and that the second entry is a readable dictionary. If we got this
  16.     % far, we know the top-level object exists and is readable, but it might
  17.     % be a dictionary.
  18.     dup type dup /arraytype ne exch /packedarraytype ne and
  19.       { /setcolorspace /typecheck signalerror }
  20.     if
  21.     dup length 2 lt
  22.       { /setcolorspace /rangecheck signalerror }
  23.     if
  24.     dup 1 get type /dicttype ne
  25.       { /setcolorspace /typecheck signalerror }
  26.     if
  27.     dup 1 get rcheck not
  28.       { /setcolorspace /invalidaccess signalerror }
  29.     if
  30.  
  31.     % Verify that the dictionary defines the key N (number of components) and
  32.     %  entry is provided and has a legitimate value
  33.     dup 1 get /N .knownget
  34.       {
  35.         //.icc_comp_map_dict exch known not
  36.           { 
  37.             % generate the appropriate error
  38.             /setcolorspace 
  39.             1 index 1 get /N type type /integertype ne
  40.               { /typecheck }
  41.               { /rangecheck }
  42.             ifelse
  43.             signalerror
  44.           }
  45.         if
  46.       }
  47.       { /setcolorspace /undefined signalerror }
  48.     ifelse
  49.  
  50.     % Verify DataSrouce and, if it is a string, convert it to a file
  51.     dup 1 get /DataSource .knownget
  52.       {
  53.         dup rcheck not
  54.           { pop /setcolorspace /invalidaccess signalerror }
  55.         if
  56.         type dup /stringtype eq
  57.           {
  58.             pop
  59.             2 array copy
  60.             dup 1
  61.              2 copy get dup length dict copy
  62.              dup /DataSource
  63.               2 copy get /ReusableStreamDecode filter
  64.              put
  65.             put
  66.           }
  67.           {
  68.             /filetype ne
  69.               { /setcolorspace /typecheck signalerror }
  70.             if
  71.           }
  72.         ifelse
  73.       }
  74.       { /setcolorspace /undefined signalerror }
  75.     ifelse
  76.  
  77.     % set the alternate color space to be the current color space
  78.     dup 1 get /Alternate .knownget not
  79.       { dup 1 get /N get //.icc_comp_map_dict exch get }
  80.     if
  81.     setcolorspace
  82.  
  83.     % if CIE spaces are not use, just take the alternate space
  84.     NOCIE
  85.       { pop //null }
  86.       { % check for native support
  87.         /.seticcspace where
  88.           { pop dup 1 get
  89.         % Acrobat Reader silently ignores errors with ICC profiles
  90.         % and uses the alternate color space -- do the same.
  91.         mark exch { .seticcspace } stopped
  92.           { cleartomark pop //null }
  93.           { pop }
  94.         ifelse
  95.       }
  96.           { pop //null }
  97.         ifelse
  98.       }
  99.     ifelse
  100.   }
  101. bind put
  102.  
  103. //userdict /.icc_comp_map_dict undef
  104.